package com.itheima;




import java.util.Scanner;
import java.util.Random;

public class java_13 {
    public static void main(String[] args) {
        int[] moneys = {100, 999, 50, 520, 1314};
        start(moneys);
    }

    public static void start(int[] moneys) {
        // 首先检查数组中是否有非零元素
        boolean hasNonZero = false;
        for (int money : moneys) {
            if (money!= 0) {
                hasNonZero = true;
                break;
            }
        }
        if (!hasNonZero) {
            System.out.println("没有可抽的红包了。");
            return;
        }

        Scanner sc = new Scanner(System.in);
        Random r = new Random();
        int originalLength = moneys.length;
        int remainingCount = originalLength;
        while (remainingCount > 0) {
            System.out.print("用户录入任意键抽奖：");
            String msg = sc.next();
            int index = r.nextInt(originalLength);
            int money = moneys[index];
            if (money!= 0) {
                System.out.println("恭喜您，您抽中了" + money + "元");
                moneys[index] = 0;
                remainingCount--;
            }
        }
        sc.close();
    }
}